package oo3;

public class Company {
	String comName, adress, jingying, tel;
	People[] pr = new People[30];

	// 显示公司的基本信息和员工信息
	public void showInfo() {
		System.out.println("本公司名叫" + comName + "，位于" + adress);
		System.out.println("主要经营" + jingying + ",电话是：" + tel);
		System.out.println("员工列表---------------");
		for (int i = 0; i < pr.length; i++) {
			if (pr[i] != null)
				System.out.println(pr[i].info());
		}
	}

	// 招人
	public void hire(People p) {
		for (int i = 0; i < pr.length; i++) {
			if (pr[i] == null) {
				pr[i] = p;
				return;
			}
		}
	}

	public void hire(String gonghao, String name, int age, String sex, String zhiwu, double xinshui) {
		for (int i = 0; i < pr.length; i++) {
			if (pr[i] == null) {
				pr[i] = new People(name, sex, zhiwu, age, xinshui, gonghao);
				return;
			}
		}
		System.out.println("公司人数已满");
	}

	// 辞退员工
	public boolean fire(String gonghao) {
		for (int i = 0; i < pr.length; i++) {
			if (pr[i] != null && pr[i].gonhao.equals(gonghao)) {
				pr[i] = null;// 没有考虑到移动的问题
				// 后面移动
				for (int j = i; j < pr.length - 1; j++)
					pr[j] = pr[j + 1];
				pr[pr.length - 1] = null;
				return true;
			}
		}
		return false;
	}

	public People getHighestSalary() {
		if (pr[0] == null)
			return null;
		People max = pr[0];
		for (int j = 1; j < pr.length; j++) {
			if (pr[j] != null && pr[j].xinshui > max.xinshui) {
				max = pr[j];
			}
		}
		return max;
	}

	// 人数
	public int count() {
		int c = 0;
		for (int i = 0; i < pr.length; i++) {
			if (pr[i] != null) {
				c++;
			}
		}
		return c;
	}
}
